"""
Case Type   : 功能测试
Case Name   : 测试表及数据准备
Create At   : 2022/05/25
Owner       : opentestcase027
Description :
    1.删除数据表13张
    2.删除数据库节点机数据文件13个
Expect      :
    1.删除数据表13张，删除成功
    2.删除数据库节点数据文件13个，删除成功
History     :
"""


import os
import unittest

from yat.test import Node
from testcase.utils.Constant import Constant
from testcase.utils.CommonSH import CommonSH
from testcase.utils.Common import Common
from testcase.utils.Logger import Logger
from yat.test import macro


logger = Logger()


class UstoreTearDown(unittest.TestCase):

    def setUp(self):
        logger.info(f'-----{os.path.basename(__file__)} 用例开始执行-----')
        self.sh_primysh = CommonSH('PrimaryDbUser')
        self.user_node = Node('PrimaryDbUser')
        self.constant = Constant()

    def test_DataDel(self):
        text = '-----step1:删除数据表，expect: 删除成功-----'
        logger.info(text)
        for i in range(1, 14):
            drop = f"""drop table t_ustore_coalesce_0038_0{i} cascade; """
            logger.info(drop)
            self.drop_res = self.sh_primysh.execut_db_sql(drop)
            logger.info(self.drop_res)
            self.assertIn(self.constant.TABLE_DROP_SUCCESS,
                          self.drop_res, '执行失败' + text)

    def tearDown(self):
        logger.info(f'----- {os.path.basename(__file__)} 执行结束-----')
